package com.ftg.learn.chapter8.pattern.singleton.innerclass;

/**
 * 数学计算 功能
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/8/1 下午1:50
 */
public class MathDeel {

    /**
     * lambda计算功能
     *
     * @param x 参数1
     * @param y 参数2
     * @param s 表达式
     * @return 与参数类型一致 int
     */
    public static int mathComputer(int x, int y, Operation s) {
        //对x 与y预处理
        return s.compute(x, y);
    }

    public static void main(String[] args) {

        Operation o = (x, y) -> x + y;

        System.out.println(o.compute(2, 3));

        Operation o1 = (x, y) -> x ^ y;

        System.out.println(o1.compute(6,7));


        System.out.println(MathDeel.mathComputer(2, 3, o));
        System.out.println(MathDeel.mathComputer(2, 3, (x, y) -> x * y));
    }

}
